//
//  StandbyContentView.swift
//  TimMusic
//
//  Created by nkl on 2024/10/25.
//

import Foundation
import SnapKit
import SwiftUI

struct StandbyContentView: View {
    @StateObject var viewModel: StandbyContentViewModel = .init()

    var didSelectedItem: (WidgetItemModel, WidgetsModel) -> Void = { _, _ in }

    var body: some View {
        ScrollView {
            LazyVStack(spacing: 20) {
                ForEach($viewModel.dataList, id: \.type) { data in
                    VStack(spacing: 20) {
                        ForEach(data.mediums, id: \.fullName) { medium in
                            AnyView(TimClassMap.map(name: medium.wrappedValue.fullName,isStatic: true)).frame(width: TimSize.scaleMediumSize.width, height: TimSize.scaleMediumSize.height).cornerRadius(22).onTapGesture {
                                didSelectedItem(medium.wrappedValue, data.wrappedValue)
                            }
                        }
                    }
                }
            }
        }.onAppear {
            viewModel.requestData()
        }
    }
}
